<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%><%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<tiles:insertDefinition name="layout">
	<tiles:putAttribute name="head">
		<script type="text/javascript">
	    $(function() {

		$(".date").datepicker({
		    showWeek : true,
		    firstDay : 1,
		    dateFormat : 'yy-mm-dd',
		    showOtherMonths : true,
		    selectOtherMonths : true,
		});

		$("#save").click(function() {
		    $.post('doImportExcel', $('#importForm').serialize(), function(data) {
			alert("ok");
			document.location.href = 'importExcel?time=' + (new Date()).getTime();
		    });
		});

	    });
	</script>
	</tiles:putAttribute>
	<tiles:putAttribute name="mainBody">
		<ul class="breadcrumb">
			<li><a href="listStudent">学员管理</a> <span class="divider">/</span></li>
			<li class="active">导入学员</li>
		</ul>
		<form method="post" action="importExcel" enctype="multipart/form-data" class="form-horizontal">
			<div class="control-group">
				<label class="control-label">文件上传</label>
				<div class="controls">
					<input name="excel" type="file" title="选择Excel文件" />
					<button type="submit" class="btn btn-primary">提交文件</button>
				</div>
			</div>
		</form>

		<div class="alert alert-block">
			点击”选择一个Excel文件“，提交一个形如
			<a href="#">XXX.xls</a>
			的Excel文件。然后再点击”提交文件“按钮，预览导入学员的情况。
		</div>
		<s:if test="#course_list.size > 0">
			<button id="save" class="btn btn-primary">保存</button>
			<span class="help-block">点击该按钮确认导入学员信息</span>
		</s:if>
		<form action="doImportExcel" method="post" id="importForm">
			<table class="table">
				<thead>
					<tr>
						<th>NO</th>
						<th>姓名</th>
						<th>学号</th>
						<th>报名日期</th>
						<th>听课证号</th>
						<th>卡号</th>
						<th>注册课程</th>
						<th>期限</th>
						<th>cc</th>
						<th>tutor</th>
						<th>开课日期</th>
						<th>结课日期</th>
						<th>课时(次)</th>
					</tr>
				</thead>
				<tbody id="selectable">
					<s:iterator value="#course_list" var="coure" status="status">
						<s:set name="exception" value="bindExceptions[#status.index]" />
						<tr class="lesson">
							<td>${status.index + 1}, ${exception}</td>
							<td><input name="name" class="input-mini" value="${coure.student.name}" type="text" /></td>
							<td><input name="stuid" class="input-mini" value="${coure.student.stuId}" type="text" /></td>
							<td><input name="signTime" class="input-small" value="<s:date name="#coure.signTime" format="yyyy-MM-dd"/>" type="text" /></td>
							<td><input name="lessonCard" class="input-small" value="${coure.lessonCard}" type="text" /></td>
							<td><input name="cardId" class="input-small" value="${coure.cardId}" type="text" /></td>
							<td><select class="input-small" name="coureId">
									<option value="-1">选择课程</option>
									<s:iterator value="courses" var="c">${c.id} ${ coure.course.id }
									<option value="${c.id }" <s:if test="#c.id==#coure.course.id">selected="selected"</s:if>>${c.name }</option>
									</s:iterator>
							</select></td>
							<td><input class="input-mini" name="term" value="${coure.term}" type="text" /></td>
							<td><select class="input-small" name="ccid">
									<option value="-1">选择CC</option>
									<s:iterator value="#ccs" var="cc">
										<option <s:if test="#coure.student.consultor.id==#cc.id">selected="selected"</s:if> value="${cc.id }">${cc.name }</option>
									</s:iterator>
							</select></td>
							<td><select class="input-small" name="tutorId">
									<option value="-1">选择Tutor</option>
									<s:iterator value="tutors" var="t">
										<option <s:if test="#t.id==#coure.student.tutor.id">selected="selected"</s:if> value="${t.id }">${t.name }</option>
									</s:iterator>
							</select></td>
							<td><input name="beginTime" class="input-small" value="<s:date name="#coure.beginTime"  format="yyyy-MM-dd" />" type="text" /></td>
							<td><input name="endTime" class="input-small" value="<s:date name="#coure.endTime"  format="yyyy-MM-dd" />" type="text" /></td>
							<td><input name="times" class="input-mini" value="${coure.times}" type="text" /></td>
						</tr>
					</s:iterator>
				</tbody>
			</table>
		</form>
	</tiles:putAttribute>
</tiles:insertDefinition>